package com.bc.mcode.controller;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

import com.bc.mcode.collect.Maps;
import com.bc.mcode.core.ClockManager;
import com.bc.mcode.core.ClockResponse;
import com.bc.mcode.util.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bc.mcode.model.ClockVO;
import com.bc.mcode.service.ClockVOService;

/**
 * @version 1.0.0
 */
@Controller
@RequestMapping("/system/clockVO")
public class ClockVOController extends BaseController {
	@Resource
	private ClockVOService clockVOService;

	//分页查询-提醒
	/*@RequestMapping("queryClockVOPageList")
	@ResponseBody
	public DatatablesViewPage<ClockVO> queryClockVOPageList(@RequestParam("iDisplayStart") Integer offset,
		@RequestParam("iDisplayLength") Integer pageSize,ClockVO clockVO){
		if(log.isDebugEnabled())log.debug("offset:" + offset + ",pagesize:"  + offset+",clockVO:" +clockVO.toJsonString());
		DataTableParamVO param = new DataTableParamVO(offset,pageSize,"clockVO",clockVO);
		return clockVOService.queryDataPageList(param);
	}
	
	//新增信息-提醒
	@RequestMapping("saveClockVO")
	@ResponseBody
	public Map<String,Object> saveClockVO(ClockVO clockVO){
		if(log.isDebugEnabled())log.debug("clockVO:"+clockVO.toJsonString());
		return clockVOService.addSelective(clockVO);
	}
	
	//修改信息-提醒
	@RequestMapping("updateClockVOById")
	@ResponseBody
	public Map<String, Object> updateClockVOById(ClockVO clockVO){
		if(log.isDebugEnabled())log.debug("clockVO:"+clockVO.toJsonString());
		return clockVOService.updateByPrimaryKeySelective(clockVO);
	}
	
	//删除信息-提醒
	@RequestMapping("deleteClockVOById")
	@ResponseBody
	public Map<String,Object> deleteClockVOById(Integer clockId,String clockTime){
		if(log.isDebugEnabled()){log.debug("clockId:"+clockId);}
		ClockManager.getInstance().deleClockVO(clockId,clockTime);
		ClockResponse.getInstance().deleClockVO(clockId);
		return clockVOService.deleteByPrimaryKey(clockId);
	}
	
	//详情查询信息-提醒
	@RequestMapping("queryClockVOById")
	@ResponseBody
	public ClockVO queryClockVOById(Integer clockId){
		if(log.isDebugEnabled()){log.debug("clockId:"+clockId);}
		return clockVOService.queryByPrimaryKey(clockId);
	}*/

	//详情查询信息-提醒
	@RequestMapping("queryTaskNum")
	@ResponseBody
	public Map<String, Object> queryTaskNum(){
		Map<String, Object> map = Maps.newHashMap();
		ClockManager manger = ClockManager.getInstance();
		ClockResponse cResponse = ClockResponse.getInstance();
		map.put("manngernum" , manger .getDataNum());
		map.put("responsenum", cResponse.getTotalDataNum());
		return map;
	}

	//详情查询信息-提醒
	@RequestMapping("getMangerData")
	@ResponseBody
	public Map<Integer, List<ClockVO>> getMangerData(){
		return  ClockManager.getInstance().getData();
	}

	//详情查询信息-提醒
	@RequestMapping("getResponseData")
	@ResponseBody
	public List<ClockVO> getResponseData(){
		return ClockResponse.getInstance().getData();
	}

}
